package com.fortune.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("login")
public class LoginController {

    @Autowired
    private HttpSession httpSession;

    @RequestMapping(value = "", method = RequestMethod.GET)
    public ModelAndView indexOfAll() throws Exception {
        ModelAndView mv = new ModelAndView("login");
        return mv;
    }

//    @RequestMapping(value = "/dologin", method = RequestMethod.POST)
//    @ResponseBody
//    public BaseResp doLogin(@RequestBody User user) throws BusinessException {
//        BaseResp resp = new BaseResp();
//        try {
//            // 校验 user 参数是否为空
//            if(StringUtils.isBlank(user.getUserName())) {
//                throw new BusinessException("用户名为空") ;
//            }
//            if(StringUtils.isBlank(user.getPassword())){
//                throw new BusinessException("密码是空");
//            }
//            // 先检查下 username 是否存在
//            User param = new User();
//            param.setUserName(user.getUserName());
//            param.setPassword(user.getPassword());
//            List<User> users = userDAO.queryByModel(param) ;
//            if(ListUtils.isEmpty(users)) {
//                throw new BusinessException("用户名或密码错误") ;
//            }
//            // 将用户放入回话中
//            User u = users.get(0) ;
//            String key = "user" ;
//            httpSession.setAttribute(key,u);
//            List<Object> orders = null ;
//        } catch (Exception ex) {
//            resp.setSuccess(false);
//            resp.setMsg(ex.getMessage());
//        }
//        return resp;
//    }


}
